package com.winspread.ui.switch

import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import androidx.cardview.widget.CardView
import com.winspread.ui.R

/**
 *Author: Amin
 *Data: 2024/6/7 13:44
 *
 *Description:
 *
 */
class CustomSwitch constructor(context: Context?, attrs: AttributeSet? = null) :
    LinearLayout(context, attrs) {

    val view: View = LayoutInflater.from(context).inflate(R.layout.custom_switch, this, true)

    private var switchSelect: Boolean? = null
    private var switchSelectColor: Int? = null
    private var switchUnSelectColor: Int? = null
    private var switchRadius: Float = 0f
    private var switchBackgroundColor: Int? = null

    init {3
        context?.obtainStyledAttributes(attrs, R.styleable.CustomSwitch)?.let {
            switchSelect = it.getBoolean(R.styleable.CustomSwitch_switch_select, false)
            switchSelectColor =
                it.getColor(R.styleable.CustomSwitch_switch_select_color, Color.WHITE)
            switchUnSelectColor =
                it.getColor(R.styleable.CustomSwitch_switch_unselect_color, Color.BLUE)
            switchRadius = it.getDimension(R.styleable.CustomSwitch_switch_Radius, 12f)
            switchBackgroundColor =
                it.getColor(R.styleable.CustomSwitch_switch_cardBackgroundColor, Color.WHITE)
            it.recycle()
        }

        view.findViewById<CardView>(R.id.cardview)?.let {
            it.radius = switchRadius
        }


    }


}